package cn.com.self.apis.portal.util;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.util.Collections;
import java.util.List;

public class CustomPage<T> extends Page<T> implements ICustomPage<T>{

    public CustomPage() {
        // to do nothing
    }

    /**
     * 分页构造函数
     *
     * @param current 当前页
     * @param size    每页显示条数
     */
    public CustomPage(long current, long size) {
        super(current, size, 0);
    }

    public CustomPage(long current, long size, long total) {
        super(current, size, total, true);
    }

    public CustomPage(long current, long size, boolean isSearchCount) {
        super(current, size, 0, isSearchCount);
    }

    public CustomPage(long current, long size, long total, boolean isSearchCount) {
        super(current,size,total,isSearchCount);
    }

    /**
     * 是否存在上一页
     *
     * @return true / false
     */
    public boolean hasPrevious() {
        return super.getCurrent() > 1;
    }

    /**
     * 是否存在下一页
     *
     * @return true / false
     */
    public boolean hasNext() {
        return super.getCurrent() < this.getPages();
    }

    @Override
    public List<T> getRecords() {
//        return Collections.emptyList();
        return null;
    }



    public List<T> getRows() {
        return super.getRecords();
    }


    @Override
    public long getTotal() {
        return super.getTotal();
    }



    @Override
    public long getSize() {
        return super.getSize();
    }



    @Override
    public long getCurrent() {
        return super.getCurrent();
    }



    public long getPage() {
        return super.getCurrent();
    }


}
